cmake_minimum_required(VERSION 3.28)

project(EigenLearn VERSION 1.0.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS ON)

# 定义调试级别选项
set(DEBUG_LEVEL "Info" CACHE STRING "Set the debug level (Off, Error, Warning, Info, Debug)")
set_property(CACHE DEBUG_LEVEL PROPERTY STRINGS Off Error Warning Info Debug)

# 根据选择的调试级别设置相应的宏定义
if(DEBUG_LEVEL STREQUAL "Debug")
    add_definitions(-DCURRENT_DEBUG_LEVEL=4)
elseif(DEBUG_LEVEL STREQUAL "Info")
    add_definitions(-DCURRENT_DEBUG_LEVEL=3)
elseif(DEBUG_LEVEL STREQUAL "Warning")
    add_definitions(-DCURRENT_DEBUG_LEVEL=2)
elseif(DEBUG_LEVEL STREQUAL "Error")
    add_definitions(-DCURRENT_DEBUG_LEVEL=1)
else()
    add_definitions(-DCURRENT_DEBUG_LEVEL=0)
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O2 -Wall -Wextra -Werror")

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)


find_package(Eigen3 REQUIRED)
if(NOT Eigen3_FOUND)
    message(FATAL_ERROR "Eigen3 not found!")
endif()

# 创建日志库作为 INTERFACE 库(只有头文件)
add_library(log INTERFACE)
# 定义日志库的头文件路径
target_include_directories(log INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src/log)

# 添加所有子目录
add_subdirectory(src/demo_01)
add_subdirectory(src/demo_02)
add_subdirectory(src/demo_03)

# 设置安装规则(可选)
# include(GNUInstallDirs)
# 为头文件库设置安装规则
# install(FILES src/log/logger.hpp
#     DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log
#     COMPONENT Development
# )
